//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CMesh.h>
///	@path	~/src/graphics/common/
///	@date	2009/01/01
///	@desc	.

#pragma once

#include "xeres.h"

#include "graphics/IVertexBuffer.h"
#include "graphics/IVertexLayout.h"
#include "graphics/IMesh.h"

namespace xeres {

	/*! 
		\class	CMesh
		\brief
	*/
	class CMesh : public IMesh
	{
	public:

		/// \ctor
		CMesh( void );

		/// \dtor
		virtual ~CMesh( void );

		DECL_IOBJECT_CLASS( CMesh , IMesh );

	public:

		/// \impl
		virtual bool OnLostDevice( void );

		/// \impl
		virtual bool OnResetDevice( RefWeak<IDevice> device );

		/// \impl
		virtual RefWeak<IVertexLayout> GetLayout( void );

		/// \impl
		virtual void EstablishBuffer( RenderContext& rc );

		/// \impl
		virtual void Draw( RenderContext& rc );

		///	\name Mesh Interface
		//@{

		/// \brief	Get vertex slot count.
		virtual size_t GetSlotCount( void );

		/// \brief	Get vertex data inside mesh.
		virtual RefWeak<IVertexBuffer> GetVertex( size_t slot );

		/// \brief	Get vertex index data.
		virtual RefWeak<IVertexIndex> GetIndex( void );

		//@}

	private:

		//@ data

		TopologyType						m_type;
		Ref<IVertexLayout>					m_layout;

		// mesh
		std::vector< Ref<IVertexBuffer> >	m_vertices;

		// index
		Ref<IVertexIndex>					m_index;

	};
	
} // namespace xeres
